<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test22</title>
</head>
<body>
    <script type="text/javascript">
        array();
        function array() {
            var arr = [18,45,0,58,32,59];
            alert("排序前："+arr);
            for(var i = 0; i<arr.length; i++){
                for(var j = 0; j<arr.length; j++){
                    if (arr[j]>arr[j+1]){
                        var a = arr[j];
                        arr[j]=arr[j+1];
                        arr[j+1]=a;
                    }
                }
            }
            alert("排序后："+arr);
        }
    </script>
</body>
</html>